﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.CMS263.PO;

namespace Com.CMS263.DAO
{
    public class AboutHelpDAO
    {
        public AboutHelpDAO(){}
        public bool Add(AboutHelp AboutHelp)
        {
            try
            {
                DBHelper.TransSaveOrUpdate(AboutHelp);
                return true;
            }
            catch
            {
                return false;
            }
        }
        public AboutHelp GetAboutHelpById(int id)
        {
            try
            {
                return DBHelper.ExecuteHQL("from AboutHelp where id=" + id).List<AboutHelp>().First();
            }
            catch
            {
                return null;
            }
        }
        public AboutHelp GetAboutHelpByTypeAndTitle(int type,string title)
        {
            try
            {
                return DBHelper.ExecuteHQL("from AboutHelp where typeId=" + type + " and title='"+title+"'").List<AboutHelp>().First();
            }
            catch
            {
                return null;
            }
        }
        public IList<AboutHelp> GetAllAboutHelp(int typeId)
        {
            return DBHelper.ExecuteHQL(" from AboutHelp where typeId="+typeId+" and  isShow=1 order by orderId desc").List<AboutHelp>();
        }
        public bool ModifyAboutHelp(AboutHelp AboutHelp)
        {
            try
            {
                DBHelper.TransUpdate(AboutHelp);
                return true;
            }
            catch
            {
                return false;
            }
        }
        public bool DeleteAboutHelpById(int id)
        {
            try
            {
                DBHelper.ExecuteHQL("delete from AboutHelp as di where di.id=" + id).ExecuteUpdate();
                return true;
            }
            catch
            {
                return false;
            }
        }


    }
}
